<template>
  <j-modal
    :visible.sync='visible'
    :width='1200'
    :title='title'
  >
    <!-- table区域-begin -->
    <template>
      <div>
        <a-table
          ref='table'
          size='middle'
          :scroll='{x:true}'
          bordered
          rowKey='id'
          :columns='columns'
          :dataSource='dataSourceModal'
          :pagination='ipagination'
          :loading='loading'
          class='j-table-force-nowrap'
          @change='handleTableChange'>

          <template slot='htmlSlot' slot-scope='text'>
            <div v-html='text'></div>
          </template>
          <template slot='imgSlot' slot-scope='text'>
            <span v-if='!text' style='font-size: 12px;font-style: italic;'>无图片</span>
            <img v-else :src='getImgView(text)' height='25px' alt=''
                 style='max-width:80px;font-size: 12px;font-style: italic;' />
          </template>
          <template slot='fileSlot' slot-scope='text'>
            <span v-if='!text' style='font-size: 12px;font-style: italic;'>无文件</span>
            <a-button
              v-else
              :ghost='true'
              type='primary'
              icon='download'
              size='small'
              @click='downloadFile(text)'>
              下载
            </a-button>
          </template>

          <span slot='action' slot-scope='text, record'>
          <a @click='handleSelect(record)'>选择</a>
        </span>

        </a-table>
      </div>
    </template>
    <template slot='footer'>
      <a-button @click='closeMessage'>关闭</a-button>
    </template>
  </j-modal>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { downFile, getAction, postAction } from '@api/manage'


export default {
  name: 'StuStudentListModal',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
  },
  props: {
    dataSourceModal: {
      type: Array,
      default: []
    },
    title: {
      type: String,
      default: '选择学生'
    }
  },
  data() {
    return {
      description: 'stu_student管理页面',
      // 表头
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '所属部门',
          align: 'center',
          dataIndex: 'sysOrgCode_dictText'
        },
        {
          title: '年级',
          align: 'left',
          dataIndex: 'gradeId_dictText'
        },
        {
          title: '班级',
          align: 'left',
          dataIndex: 'classId_dictText'
        },
        {
          title: '学生学号',
          align: 'center',
          dataIndex: 'studentNo'
        },
        {
          title: '学生姓名',
          align: 'center',
          dataIndex: 'studentName'
        },
        {
          title: '登录账号',
          align: 'center',
          dataIndex: 'userId_dictText'
        },
        {
          title: '身份证号',
          align: 'center',
          dataIndex: 'studentIdCardNo'
        },
        {
          title: '卡号',
          align: 'center',
          dataIndex: 'studentCardNo'
        },
        {
          title: '学生性别',
          align: 'center',
          dataIndex: 'studentGender_dictText'
        },
        {
          title: '出生年月',
          align: 'center',
          dataIndex: 'studentDateBirth',
          customRender: function(text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '民族',
          align: 'center',
          dataIndex: 'studentNation_dictText'
        },
        {
          title: '联系电话',
          align: 'center',
          dataIndex: 'studentTelephone'
        },
        {
          title: '入学年份',
          align: 'center',
          dataIndex: 'studentEnrollmentYear'
        },
        {
          title: '学生微信',
          align: 'center',
          dataIndex: 'studentWechat'
        },
        {
          title: '学生邮箱',
          align: 'center',
          dataIndex: 'studentEmail'
        },
        {
          title: '学生QQ',
          align: 'center',
          dataIndex: 'studentQq'
        },
        {
          title: '身高',
          align: 'center',
          dataIndex: 'studentHeight'
        },
        {
          title: '体重',
          align: 'center',
          dataIndex: 'studentWeight'
        },
        {
          title: '视力',
          align: 'center',
          dataIndex: 'studentVision'
        },
        {
          title: '来源学校',
          align: 'center',
          dataIndex: 'studentFromSchool'
        },
        {
          title: '毕业去向',
          align: 'center',
          dataIndex: 'studentGraduationDestination'
        },
        {
          title: '户籍地址',
          align: 'center',
          dataIndex: 'studentHouseholdRegister'
        },
        {
          title: '生源地',
          align: 'center',
          dataIndex: 'studentPlaceOrigin'
        },
        {
          title: '现住地址',
          align: 'center',
          dataIndex: 'studentCurrentAddress'
        },
        {
          title: '学生类型',
          align: 'center',
          dataIndex: 'studentTtype_dictText'
        },
        {
          title: '家庭状态',
          align: 'center',
          dataIndex: 'studentFamilyStatus_dictText'
        },
        {
          title: '是否贫困生',
          align: 'center',
          dataIndex: 'studentPoor_dictText'
        },
        {
          title: '贫困级别',
          align: 'center',
          dataIndex: 'studentPoorLevel_dictText'
        },
        {
          title: '是否借读生',
          align: 'center',
          dataIndex: 'studentLoan_dictText'
        },
        {
          title: '特殊标识',
          align: 'center',
          dataIndex: 'studentSpecialFlag'
        },
        {
          title: '紧急联系人',
          align: 'center',
          dataIndex: 'studentEmergencyContact'
        },
        {
          title: '紧急人联系电话',
          align: 'center',
          dataIndex: 'studentEmergencyTelephone'
        },
        {
          title: '学生状态',
          align: 'center',
          dataIndex: 'studentStatus_dictText'
        },
        {
          title: '排序号',
          align: 'center',
          dataIndex: 'studentOrder'
        },
        {
          title: '是否启用',
          align: 'center',
          dataIndex: 'studentIzOpen_dictText'
        },
        // {
        //   title:'学校编码',
        //   align:"center",
        //   dataIndex: 'tenantId'
        // },
        {
          title: '是否删除',
          align: 'center',
          dataIndex: 'studentIzDelete_dictText'
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'studentRemark'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      dictOptions: {},
      superFieldList: [],
      visible: false
    }
  },
  created() {
  },
  computed: {},
  mounted() {
  },
  methods: {
    loadData() {

    },
    openModal() {
      if (this.visible === false) {
        this.visible = true
      }
    },
    closeMessage() {
      if (this.visible === true) {
        this.visible = false
      }
      this.$bus.$emit('closeStuStudentListModal', {})
    },
    handleSelect(val) {
      if (this.visible === true) {
        this.visible = false
      }
      this.$bus.$emit('closeStuStudentListModal', val)
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>